import {pget, ppostJson} from '@/utils/req'
import {modalApi} from '@/utils/modalReq'

// 证照补办申请列表
export function getTableList(query: any) {
	return pget(`${modalApi.carMessage}/assetslicenserenewal/page`, query)
}

// 新增证照补办申请
export function addRenewal(data: any) {
	return ppostJson(`${modalApi.carMessage}/assetslicenserenewal/save`, data)
}

// 修改证照补办申请
export function editRenewal(data: any) {
	return ppostJson(`${modalApi.carMessage}/assetslicenserenewal/update`, data)
}

// 删除证照补办申请
export function deleteRenewal(ids: string) {
	return ppostJson(
		`${modalApi.carMessage}/assetslicenserenewal/remove?ids=${ids}`,
	)
}

// 查看证照补办申请
export function viewRenewal(query?: any) {
	return pget(`${modalApi.carMessage}/assetslicenserenewal/detail`, query)
}

// 根据类型查询补办列表
export function getTablePage(renewalType: any, query: any) {
	return pget(
		`${modalApi.carMessage}/assetscarcertificate/getRenewalInfo/${renewalType}`,
		query,
	)
}

// 自动生成补办文件接口
export function autoRenewalExport(query: any) {
	return pget(
		`${modalApi.carMessage}/assetslicenserenewal/certificateExport`,
		query,
		{
			headers: {
				'transfer-encoding': 'chunked',
				'content-type': 'application/vnd.ms-excel;charset=UTF-8',
				'response-type': 'text',
			},
		},
	)
}

// 工作流接口
/** 流程发起 */
export function renewalProcessAdd(data: any) {
	return ppostJson(`${modalApi.carMessage}/renewalApprove/submitFlow`, data)
}
// 证照补办审核
export function renewalAuditFlow(data: any) {
	return ppostJson(`${modalApi.carMessage}/renewalApprove/auditFlow`, data)
}
// 作废证照补办后重新发起审核
export function renewalRelaunchFlow(id: any, data: any) {
	return ppostJson(
		`${modalApi.carMessage}/shopec-purchase-contract/contract/relaunchFlow/${id}`,
		data,
	)
}
// 判断流程是否开启
export function getIsProcessOpen(query: any) {
	return pget(`${modalApi.carMessage}/approveUtil/isProcessOpen`, query)
}
// 判断是否显示驳回按钮
export function getNodePropertys(query: any) {
	return pget(`${modalApi.carMessage}/approveUtil/getNodePropertys`, query)
}
